package com.zfl.thread.day02;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ExecutorServiceDemo01 {
    public static void main(String[] args) {
        /**
         * 创建可扩展线程池对象
         * 向线程池中添加50个任务
         */
        ExecutorService executorService = Executors.newCachedThreadPool();
        for (int i = 0; i < 50; i++) {
            int finalI = i;
            executorService.execute(()->{
               System.out.println(Thread.currentThread().getName()+"正在执行第"+ finalI +"个任务");
            });
        }

        executorService.shutdown();

    }
}
